package com.library.popup;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.mvc.AbstractFormController;

import com.library.model.dto.zipcode.ZipcodeDTO;
import com.library.model.service.ZipcodeService;

public class AddressFormController extends AbstractFormController{
	private ZipcodeService zipcodeservice;	

	public void setZipcodeservice(ZipcodeService zipcodeservice) {
		this.zipcodeservice = zipcodeservice;
	}

	@Override
	protected ModelAndView processFormSubmission(HttpServletRequest request,
			HttpServletResponse response, Object arg2, BindException arg3)
			throws Exception {
		ModelAndView mav=new ModelAndView();
		String z_dong=request.getParameter("z_dong");
		mav.addObject("dong",z_dong);
		List list=zipcodeservice.getZipcode((ZipcodeDTO)arg2);
		mav.addObject("list",list);
		mav.setViewName("addressform");
		return mav;
	}

	@Override
	protected ModelAndView showForm(HttpServletRequest arg0,
			HttpServletResponse arg1, BindException arg2) throws Exception {
		return new ModelAndView("addressform");
	}

}
